/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package com.cnbm.modules.sys.controller;

import com.cnbm.common.utils.PageUtils;
import com.cnbm.common.utils.R;
import com.cnbm.modules.sys.service.SysLogService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * @Author weihongyang
 * @Date 2020/8/10 15:46
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/log")
public class SysLogController {
	@Autowired
	private SysLogService sysLogService;
	
	/**
	 * 列表
	 */
	@GetMapping("/list")
	@RequiresPermissions("sys:log:list")
	public R list(@RequestParam Map<String, Object> params){
		PageUtils page = sysLogService.queryPage(params);

		return R.ok().put("page", page);
	}


	/**
	 * 条件列表
	 */
	@PostMapping("/list/by/term")
	@ApiOperation(value = "获取日志", notes = "获取日志")
	public R listByTerm(@RequestBody Map<String, Object> params){
		System.err.println(params.toString());

//		HashMap<String,Object> params = new HashMap<>();
//
//		params.put("page",1);
//
//		params.put("limit",10);
//		params.put("username","");
//
//		List<String> list = new ArrayList<>();
//		list.add("保存用户");
//		list.add("修改用户");
//		params.put("operation",list);
//
//		System.err.println(params.toString());

		PageUtils page = sysLogService.listByTerm(params);

		return R.ok().put("page", page);
	}

	/**
	 * 操作类型
	 */
	@GetMapping("/operation/list")
	public R operationList(){
		PageUtils page = sysLogService.operationList();

		return R.ok().put("page", page);
	}
	
}
